package springasync;

import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.AsyncResult;

import java.util.Random;
import java.util.concurrent.Future;

/**
 * @ClassName AsynchronousService
 * @Description
 * @Author yuhang11
 * @Date 2022/1/4 2:53 下午
 * @Version 1.0
 */
public class AsynchronousService {
    @Async
    public Future springAsynchronousMethod(){
        Integer result = new Random().nextInt();
        System.out.println("子线程计算得到："+result);
        return new AsyncResult(result);
    }
}
